/*
** 2388.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Mon Oct 13 21:27:33 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/
/*
 * EXPERIENCE: a detailed to bone algorithm....
 */

/* #include "2388.h" */
#include <stdio.h>
#define SWAP(a, b)\
     do{	  \
	  register int tmp = (b);		\
	  (b) = (a);				\
	  (a) = tmp;				\
     }while(0)					\
     
int main()
{
     int mp[10002], N, i;	/* mp[0],mp[10001] for preventing out
				 * of range */
     int l, r;
     int lc, rc;		/* left cursor, right cursor */
     static char out_of_range;
     
     scanf("%d", &N);
     for(i = 1; i <= N; i++)
	  scanf("%d", mp + i);
     for(i = N+2; i < 10002; i++)
	  mp[i] = 0;
     
     mp[0] = 2000000;
     mp[N+1] = 0;

     l = 1, r = N;
     i = (l + r) / 2;		/* can be switched to other
				 * generating functions */
     SWAP(mp[l], mp[i]);
     while(1){ /* i:intermediate */
	  lc = l + 1, rc = r;	/* set up cursors */
	  out_of_range = 0;
	  do{
	       while(mp[lc] < mp[l]) lc++;
	       while(mp[rc] >= mp[l]) rc--;
	       if (lc > r)
		    out_of_range = 1; /* all smaller */
	       else if (rc < l)
		    out_of_range = 2; /* all larger or equal */
	       else SWAP(mp[lc], mp[rc]);
	  }while(lc < rc);
	  if (out_of_range == 0){
	       SWAP(mp[rc], mp[lc]); /* now rc = lc - 1 */
	       if (rc < (N+1)/2){
		    l = lc;
		    i = (l+r)/2; /* other generating functions */
		    SWAP(mp[l], mp[i]); 
	       }
	       else if (rc == (N+1)/2){
		    printf("%d\n", mp[l]);
		    return 0;/* return mp[l] if functionalized */
	       }
	       else{
		    r = rc;
		    i = (l+r)/2;
		    SWAP(mp[l], mp[i]);
	       }
	  }
	  else if (out_of_range == 1)
	       if (r == (N+1)/2){
		    printf("%d\n", mp[l]);
		    return 0;	/* return mp[l] if functionalized */
	       }
	       else{
		    SWAP(mp[l], mp[r]); /* pay attention to -- ++ in macro */
		    i = (l+r) / 2; /* other generating functions */
		    SWAP(mp[l], mp[i]);
	       }
	  else if (out_of_range == 2){
	       for(lc = l; mp[lc] == mp[l]; lc++);
	       if (lc > (N+1)/2){ /* this must be the intermediate */
		    printf("%d\n", mp[l]);
		    return 0;	/* return mp[l] if functionalized */
	       }
	       else
		    l = lc;
	  }
	  else{
	       perror("Runtime error!!!\n");
	       return 1;
	  }
     }

     return 0;
}

